package priv.menguer.flyweight.controller;

import java.util.HashMap;

import priv.menguer.flyweight.service.Shape;
import priv.menguer.flyweight.service.impl.Circle;

/**
 * @Title ShapeFactory.java
 * @description TODO
 * @time 2018年10月26日 上午10:34:34
 * @author menguer@126.com
 * @version 1.0
 */
public class ShapeFactory {
	private static final HashMap<String, Shape> circleMap = new HashMap<>();

	public static Shape getCircle(String color) {
		Circle circle = (Circle) circleMap.get(color);

		if (circle == null) {
			circle = new Circle(color);
			circleMap.put(color, circle);
			System.out.println("Creating circle of color : " + color);
		}
		return circle;
	}
}
